<?php
namespace app\api\controller;
use app\common\model\user\User as UserModel;

class Rolepower extends Base
{
	/**
	 * 产生jwt加密串，参考session
	 */
    public function initialize(){
		parent::initialize();
		self::is_login();
	}

	 /**
     * 返回用户名称和手机号
     * @return [type] [description]
     */
    public function getpower(){
        $userlogininfo = Pub::getuserid();
        if(!$userlogininfo['code']){
            return myerr($userlogininfo['msg']);
        }
        $data = UserModel::getinfo();
        $rdata['username'] = $data->Name;
        $rdata['iphone']  = $data->Iphone;
        $rdata['rolename'] = getrolename($data->Role);
        return myok($rdata);
    } 

	/**
	 * 判断账号是否登录
	 * @return boolean [description]
	 */
	private function is_login(){
		$data = UserModel::is_sessionlogin();
		if (!$data['code']) {
			$data['options'] = 'relogin';
			json($data)->send();
			exit;
		}
	}
}
